import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules ,longLimtVal} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '代码',
    align:"center",
    dataIndex: 'dm',
    fixed: 'left'

   },
   {
    title: '名称',
    align:"center",
    dataIndex: 'mc',
    fixed: 'left'

   },
   {
    title: '工业区',
    align:"center",
    dataIndex: 'gyq',
    fixed: 'left'
   },
   {
    title: '代扣银行',
    align:"center",
    dataIndex: 'bank'
   },
  {
    title: '代扣帐号',
    align:"center",
    dataIndex: 'ckCode'
  },
  {
    title: '税号',
    align:"center",
    dataIndex: 'shh'
  },

   {
    title: '电话',
    align:"center",
    dataIndex: 'dh'
   },
  {
    title: '邮箱',
    align:"center",
    dataIndex: 'email'
  },
   {
    title: '联系人',
    align:"center",
    dataIndex: 'lxr'
   },
   {
    title: '商号名称',
    align:"center",
    dataIndex: 'shmc'
   },
   {
    title: '地址',
    align:"center",
    dataIndex: 'dz'
   },
   {
    title: '商号电话',
    align:"center",
    dataIndex: 'shdh'
   },
   {
    title: '企业性质',
    align:"center",
    dataIndex: 'qyxz'
   },
   {
    title: '所属行业',
    align:"center",
    dataIndex: 'sshy'
   },
   {
    title: '投资形式',
    align:"center",
    dataIndex: 'tzxs'
   },
   {
    title: '投资来源',
    align:"center",
    dataIndex: 'tzly'
   },
  {
    title: '母公司',
    align:"center",
    dataIndex: 'parentname',
    customRender:({text})=>{
      if(text=='0')
        return '';
    }
  },
  {
    title: '风险类型',
    align:"center",
    dataIndex: 'risktype'
  },
   {
    title: '备注',
    align:"center",
    dataIndex: 'bz'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "名称",
      field: 'mc',
      component: 'JInput',
      colProps: {span: 6},
 	},
  {
    label: "企业性质",
    field: 'qyxz',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_QYXZB,QYXZ,QYXZ"
    },
    colProps: {span: 6},
  },
  {
    label: "所属行业",
    field: 'sshy',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_HYLXB,HYLX,HYLX"
    },
    colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '代码',
    field: 'dm',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { 
                  required: true, 
                  message: '请输入代码!',
                  validator: (_, value) => {
                    return longLimtVal(value,8)
                  },
                },
          ];
     },
  },
  {
    label: '名称',
    field: 'mc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { 
                  required: true, 
                  message: '请输入名称!',
                  validator: (_, value) => {
                    return longLimtVal(value,25)
                  },
                },
          ];
     },
  },
  {
    label: '工业区',
    field: 'gyq',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_GYQB,GRQ_NAME,GRQ_NAME"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入工业区!'},
          ];
     },
  },
  {
    label: '代扣银行',
    field: 'bank',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_BANK,BA_NAME,BA_NAME"
    },
  },
  {
    label: '代扣帐号',
    field: 'ckCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,30)
          },
        },
      ];
    }
  },
  {
    label: '税号',
    field: 'shh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,50)
          },
        },
      ];
    }
  },
  {
    label: '电话',
    field: 'dh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,16)
          },
        },
      ];
    }
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,50)
          },
        },
      ];
    }
  },
  {
    label: '联系人',
    field: 'lxr',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,5)
          },
        },
      ];
    }
  },
  {
    label: '商号名称',
    field: 'shmc',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,24)
          },
        },
      ];
    }
  },
  {
    label: '地址',
    field: 'dz',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,24)
          },
        },
      ];
    }
  },
  {
    label: '商号电话',
    field: 'shdh',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { 
          validator: (_, value) => {
            return longLimtVal(value,16)
          },
        },
      ];
    }
  },
  {
    label: '企业性质',
    field: 'qyxz',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_QYXZB,QYXZ,QYXZ"
     },
  },
  {
    label: "所属行业",
    field: 'sshy',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_HYLXB,HYLX,HYLX"
    },
  },
  {
    label: '投资形式',
    field: 'tzxs',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_TZXSB,TZXS,TZXS"
    },
  },
  {
    label: '投资来源',
    field: 'tzly',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"DB_TZLYB,TZLY,TZLY"
    },
  },
  {
    label: '风险类型',
    field: 'risktype',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:'risk_type'
    }
  },
  {
    label: '母公司',
    field: 'parentname',
    component: 'JSearchSelect',
    componentProps: {
      dict: "DB_QYZLB,MC,MC",
      async:true,
      pageSize:10,
    },
  },

  {
    label: '备注',
    field: 'bz',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
